#include <iostream>
#include <math.h>
using namespace std;


int gcd(int a,int b){
	if(a == 0)
		return b;
	if(b == 0)
		return a;
	if(a > b)
		return gcd(a%b,b);
	else
		return gcd(a,b%a);
}


struct num{
	int p,q;
	void operator += (num x){
		int cd=gcd(q,x.q),ed=q*x.q/cd;
		p = p*(ed/q);
		x.p = x.p*(ed/x.q);
		p = p+x.p;
		q = ed;
		cd = gcd(abs(p),q);
		p /= cd;
		q /= cd;
//		cout<<x.p<<" "<<q<<endl;
	}
	void operator -= (num x){
		int cd=gcd(q,x.q),ed=q*x.q/cd;
		p = p*(ed/q);
		x.p = x.p*(ed/x.q);
		p = p-x.p;
		q = ed;
		cd = gcd(abs(p),q);
		p /= cd;
		q /= cd;
//		cout<<p<<" "<<q<<endl;
	}
};



int main(){
	num ans;
	ans.p = 0;
	ans.q = 1;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		num l;
		int ord;
		cin>>l.p>>l.q>>ord;
		if(ord == 1){
			ans += l;
		}
		else{
			ans -= l;
		}
//		cout<<"		"<<ans.p<<"/"<<ans.q<<endl;
	}
	cout<<ans.p<<"/"<<ans.q;
	return 0;
}
